import java.util.Random;
import java.util.Scanner;

public class 减乘除 {
    public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
        Random random = new Random();
        int ts;//题数
        int fw;//范围
        int ddts = 0, dcts = 0;//答对题数，答错题数
        System.out.println("==========欢迎使用口算答题系统==========");
        while (true) {
            System.out.println("请选择题目类型");
            System.out.println("  1==加法 " + "  2==减法  " + "  3==乘法  " + "  4==除法  " + "5==退出程序");
            int n = scan.nextInt();
            switch (n) {
                case 1: {
                    System.out.println("请输入题数");
                    ts = scan.nextInt();
                    System.out.println("请输入数值范围");
                    fw = scan.nextInt();
                    for (int i = 0; i < ts; i++) {
                        int n1 = random.nextInt(fw + 1);
                        int n2 = random.nextInt(fw + 1);
                        System.out.print(n1 + "+" + n2 + "=");
                        System.out.println("请输入您的答案");
                        int daan = scan.nextInt();//输入答案
                        if (daan == n1 + n2) {
                            System.out.println("恭喜你答对了");
                            ddts++;
                        }        //ddts++              ddts = ddts+1
                        else {
                            System.out.println("哎呦答错了，要继续加油哦");
                            dcts++;
                        }
                    }
                    break;
                }


             case 2: {
                    System.out.println("请输入题数");
                    ts = scan.nextInt();
                    System.out.println("请输入数值范围");
                    fw = scan.nextInt();
                    for (int i = 0; i < ts; i++) {
                        int n1 = random.nextInt(fw + 1);
                        int n2 = random.nextInt(fw + 1);
                        System.out.println(n1 + "-" + n2 + "=");
                        System.out.println("请输入您的答案");
                        int daan = scan.nextInt();//答案
                        if (daan == n1 - n2) {
                            System.out.println("恭喜你答对了");
                            ddts++;
                        } else {
                            System.out.println("哎呦答错了，要继续加油哦");
                            dcts++;
                        }


                    }
                    break;
                }


                case 3: {
                    {
                        System.out.println("请输入题数");
                        ts = scan.nextInt();
                        System.out.println("请输入数值范围");
                        fw = scan.nextInt();
                        for (int i = 0; i < ts; i++) {
                            int n1 = random.nextInt(fw + 1);
                            int n2 = random.nextInt(fw + 1);
                            System.out.println(n1 + "*" + n2 + "=");
                            System.out.println("请输入您的答案");
                            int daan = scan.nextInt();//答案
                            if (daan == n1 * n2) {
                                System.out.println("恭喜你答对了");
                                ddts++;
                            } else {
                                System.out.println("哎呦答错了，要继续加油哦");
                                dcts++;
                            }

                        }
                        break;
                    }
                }
                case 4: {
                    System.out.println("请输入题数");
                    ts = scan.nextInt();
                    System.out.println("请输入数值范围");
                    fw = scan.nextInt();
                    for (int i = 0; i < ts; i++) {
                        int n1 = random.nextInt(fw + 1);
                        int n2 = random.nextInt(fw) + 1;
                        int c;


                        if (n1 !=1&&n1 < n2) {
                            c = n1;
                            n1 = n2;
                            n2 = c;
                        }

                        if (n1 % n2 == 0) {
                            System.out.println(n1 + "/" + n2 + "=");
                            System.out.println("请输入您的答案");
                            int dn = scan.nextInt();//答案
                            if (dn == n1 / n2){
                                System.out.println("恭喜你答对了");
                            ddts++;
                        } else {
                            System.out.println("哎呦答错了，要继续加油哦");
                            dcts++;
                        }

                    }}
                    break;


                } case 5:

            System.out.println("==========您已退出*谢谢使用==========");
            System.exit(4);//退出程序
        }

        System.out.println("您一共" + "答对了" + ddts + "道题" + "答错了" + dcts + "道题");
        System.out.println("请继续选择服务项目");}
                }}











































